package kaobei;

/**
 * @Created by pic
 * @Time 2019/9/2 0002
 * @Package cn.bdpro02.clonedemo
 * @Desc
 */
public class TestClone {
    public static void main(String[] args) throws CloneNotSupportedException {
        Cat sunbin = new Cat("sunbin", 3);
        Lady huamulan = new Lady("huamulan", 18, sunbin);
    /*    Lady niming = huamulan;//浅拷贝   只拷贝地址
        System.out.println(niming);
        huamulan.setAge(28);
        System.out.println(niming);*/

        //如果实现了cloneable接口那么就是深拷贝,会开辟新的空间,但是该类中的成员对象默认是浅拷贝
        Lady clone = (Lady)huamulan.clone();
        huamulan.setAge(28);
        System.out.println(huamulan.getCat());
        System.out.println(clone.getCat());
    }
}
